// model kinds service
var app = angular.module('app');
app.factory('modelKindsService', [function () {
    var modelKindsService = {};
    modelKindsService.kinds = [{index: 0, name: '活动', value: 'activity'},
        {index: 1, name: '资讯', value: 'information'},
        {index: 2, name: '视频', value: 'video'},
        {index: 3, name: '广告', value: 'advertisement'},
        {index: 4, name: '专题', value: 'topic'},
        {index: 5, name: '事件', value: 'event'},
        {index: 6, name: '首页', value: 'homepage'}];

    modelKindsService.getByName = function (name) {
        if (!name) {
            return undefined;
        }
        var result = undefined;
        for (var i = 0; i < modelKindsService.kinds.length; i++) {
            if (name == modelKindsService.kinds[i].name) {
                result = modelKindsService.kinds[i];
                break;
            }
        }
        return result;
    };

    modelKindsService.getByIndex = function (index) {
        var result = undefined;
        for (var i = 0; i < modelKindsService.kinds.length; i++) {
            if (index == modelKindsService.kinds[i].index) {
                result = modelKindsService.kinds[i];
                break;
            }
        }

        return result;
    };

    return modelKindsService;
}]);